import { ref, onMounted, getCurrentInstance } from 'vue'
import { shake } from '../utils/shake'

interface chartType {
    [key: string]: any
}

// 定义函数
const resize = () => {
    // console.log(123, getCurrentInstance());
    // const mycharts = ref()
    onMounted(() => {
        const { proxy } = getCurrentInstance()!
        window.addEventListener('resize', shake(() => {
            (proxy!.$refs.mycharts! as chartType).charts && (proxy!.$refs.mycharts! as chartType).charts.resize()
        }, 150))
    })
}
// 导出
export default resize
